home *** CD-ROM | disk | FTP | other *** search
/ Delphi 2 - Developers' Solutions / Delphi 2 Developers' Solutions.iso / dds / chap02 / howto09 / delphi10 / ufmgr9.pas < prev   
Encoding:
Pascal/Delphi Source File  |  1995-10-14  |  23.0 KB  |  637 lines

  1. unit Ufmgr9;
  2.  
  3. interface
  4.  
  5. uses
  6.   SysUtils, WinTypes, WinProcs, Messages, Classes, Graphics, Controls,
  7.   Forms, Dialogs, StdCtrls, Buttons, ExtCtrls, ShellAPI, FileCtrl,
  8.    DRWSUtl1, DRWSUtl2;
  9.  
  10. type
  11.   TCCFileMgrForm = class(TForm)
  12.     Panel1: TPanel;
  13.     Panel2: TPanel;
  14.     BitBtn1: TBitBtn;
  15.     Panel3: TPanel;
  16.     Label1: TLabel;
  17.     BitBtn2: TBitBtn;
  18.     BitBtn3: TBitBtn;
  19.     BitBtn4: TBitBtn;
  20.     BitBtn5: TBitBtn;
  21.     BitBtn6: TBitBtn;
  22.     BitBtn7: TBitBtn;
  23.     OpenDialog1: TOpenDialog;
  24.     BitBtn8: TBitBtn;
  25.     BitBtn9: TBitBtn;
  26.     OpenDialog2: TOpenDialog;
  27.     procedure FormResize(Sender: TObject);
  28.     procedure FormCreate(Sender: TObject);
  29.     procedure BitBtn7Click(Sender: TObject);
  30.     procedure BitBtn1Click(Sender: TObject);
  31.     procedure BitBtn2Click(Sender: TObject);
  32.     procedure BitBtn3Click(Sender: TObject);
  33.     procedure BitBtn4Click(Sender: TObject);
  34.     procedure BitBtn5Click(Sender: TObject);
  35.     procedure FormPaint(Sender: TObject);
  36.     procedure BitBtn8Click(Sender: TObject);
  37.     procedure BitBtn9Click(Sender: TObject);
  38.     procedure BitBtn6Click(Sender: TObject);
  39.     procedure BitBtn1DragDrop(Sender, Source: TObject; X, Y: Integer);
  40.     procedure BitBtn1DragOver(Sender, Source: TObject; X, Y: Integer;
  41.       State: TDragState; var Accept: Boolean);
  42.     procedure BitBtn2DragDrop(Sender, Source: TObject; X, Y: Integer);
  43.     procedure BitBtn3DragDrop(Sender, Source: TObject; X, Y: Integer);
  44.     procedure BitBtn4DragDrop(Sender, Source: TObject; X, Y: Integer);
  45.   private
  46.     { Private declarations }
  47.   public
  48.     { Public declarations }
  49.     DirectoryListBox1 : TDirectoryListBox;
  50.     FileListBox1 : TIconFileListBox;
  51.     ScrollBox1 : TFileIconPanelScrollbox;
  52.   end;
  53. var
  54.   CCFileMgrForm      : TCCFileMgrForm;
  55.   CurrentView        : Integer;  { This holds the current view setting      }
  56.  
  57. implementation
  58.  
  59. {$R *.DFM}
  60.  
  61. uses DDDFUnit,  { Include custom directory selection form }
  62.      CfmpfUn;   { Include custom options dialog           }
  63.  
  64. { Set up the resize to replace the icon buttons }
  65. procedure TCCFileMgrForm.FormResize(Sender: TObject);
  66. begin
  67.   { Send in the panel and global buttons list }
  68.   SpacePanelButtons( Panel2 );
  69. end;
  70.  
  71. { Delphi wrote this; use it to set everything up }
  72. procedure TCCFileMgrForm.FormCreate(Sender: TObject);
  73. var TheIconPanel : TFileIconPanel;
  74.     CurrentPath : String;
  75. begin
  76.   { Create the directory list box }
  77.   DirectoryListBox1 := TDirectoryListBox.Create( Panel1 );
  78.   DirectoryListBox1.Parent := Panel1;
  79.   DirectoryListBox1.Visible := true;
  80.   DirectoryListbox1.Top := 17;
  81.   DirectoryListbox1.Left := 0;
  82.   DirectoryListbox1.Height := Panel1.Height - 32;
  83.   DirectoryListbox1.Width := 0;
  84.   { Create the file list box }
  85.   FileListBox1 := TIconFileListBox.Create( Panel1 );
  86.   FileListBox1.Parent := Panel1;
  87.   FileListbox1.Top := 17;
  88.   FileListbox1.Left := 146;
  89.   FileListbox1.Height := Panel1.Height - 32;
  90.   FileListbox1.Width := 0;
  91.   FileListBox1.Visible := true;
  92.   FileListBox1.ShowGlyphs := true;
  93.   { Set intercomponent interactions }
  94.   DirectoryListBox1.FileList := FileListbox1;
  95.   DirectoryListBox1.DirLabel := Label1;
  96.   { Create the scrollbox }
  97.   ScrollBox1 := TFileIconPanelScrollBox.Create( Panel1 );
  98.   ScrollBox1.Parent := Panel1;
  99.   ScrollBox1.align := alClient;
  100.   ScrollBox1.Left := 0;
  101.   ScrollBox1.Top := 0;
  102.   ScrollBox1.Width := Panel1.Width - 32;
  103.   ScrollBox1.Height := Panel1.Height - 32;
  104.   ScrollBox1.IconsNeedRefreshing := false;
  105.   ScrollBox1.TheStoredHandle := Self.Handle;
  106.   { Get the current directory with 0 parameter }
  107.   GetDir( 0 , CurrentPath );
  108.   { Set the display caption }
  109.   Label1.Caption := CurrentPath;
  110.   { Add a trailing \ if not root }
  111.   CurrentPath := ScrollBox1.TheFWB.ForceTrailingBackSlash( CurrentPath );
  112.   { Get the icons display using scrollbox1 }
  113.   ScrollBox1.GetIconsForEntireDirectory( CurrentPath );
  114.   { Set the Icon View as default }
  115.   CurrentView := 1;
  116. end;
  117.  
  118. { Delphi wrote this; use it to close the application }
  119. procedure TCCFileMgrForm.BitBtn7Click(Sender: TObject);
  120. begin
  121.   Close;
  122. end;
  123.  
  124. { Delphi wrote this use it to perform a copy on all selected files }
  125. procedure TCCFileMgrForm.BitBtn1Click(Sender: TObject);
  126. var ThePosition  : Integer;       { Loop counter   }
  127.     CurrentName ,                 { Holds work name}
  128.     TheOldString : String;        { Holds Dir      }
  129.     finished     : Boolean;       { Loop control   }
  130.     WorkingDir   : String;        { Holds mod wd   }
  131.     TargetDir    : String;        { target of op   }
  132.     TheResult    : Integer;       { Modal res hold }
  133. begin
  134.   { Get current directory and save it for later }
  135.   GetDir( 0 , TheOldString );
  136.   { Check for need to add trailing \ }
  137.   WorkingDir := TheOldString;
  138.   WorkingDir := ScrollBox1.TheFWB.ForceTrailingBackSlash( WorkingDir );
  139.   { Display the Windows-based directory input form }
  140.   TheResult := DestDDForm.ShowModal;
  141.   { If not cancelled do the copy }
  142.   if TheResult = mrOK then
  143.   begin
  144.     { Get the target directory with \ OK }
  145.     TargetDir := DestDDForm.GetTargetDirectory;
  146.     { Show the hourglass to indicate waiting }
  147.     Screen.Cursor := crHourGlass;
  148.     { Setup to get all selections }
  149.     ThePosition := 1;
  150.     finished := false;
  151.     while not finished do
  152.     begin
  153.       { Call generic file getting routine based on current view}
  154.       case CurrentView of
  155.         1 : CurrentName := ScrollBox1.GetNextSelection( WorkingDir ,
  156.              ThePosition );
  157.         2 : CurrentName := FileListBox1.GetNextSelection( WorkingDir ,
  158.              ThePosition );
  159.       end;
  160.       { If returns blank string out of selections so exit }
  161.       if CurrentName = '' then finished := true else
  162.       begin
  163.         { If a directory signal error }
  164.         if (( FileGetAttr( CurrentName ) and faDirectory ) = faDirectory ) then
  165.         begin
  166.           if MessageDlg( 'Copy Directory ' + CurrentName + ' to ' + TargetDir
  167.            +'?', mtConfirmation , mbYesNoCancel , 0 ) = mryes then
  168.           begin
  169.             ScrollBox1.TheFWB.RecursivelyCopyDirectory( CurrentName ,
  170.              TargetDir );
  171.           end;
  172.         end
  173.         else
  174.         begin
  175.           Scrollbox1.TheFWB.CopyTheFile( CurrentName , TargetDir );
  176.         end;
  177.       end;
  178.     end;
  179.     { Reset to normal cursor }
  180.     Screen.Cursor := crDefault;
  181.   end;
  182.   { Reset to the original directory }
  183.   ChDir( TheOldString );
  184. end;
  185.  
  186. { Delphi wrote this, use it to move files which are selected }
  187. procedure TCCFileMgrForm.BitBtn2Click(Sender: TObject);
  188. var ThePosition  : Integer;       { Loop counter   }
  189.     CurrentName ,                 { Holds work name}
  190.     TheOldString : String;        { Holds Dir      }
  191.     finished     : Boolean;       { Loop control   }
  192.     WorkingDir   : String;        { Holds mod wd   }
  193.     TargetDir    : String;        { target of op   }
  194.     TheResult    : Integer;       { Modal res hold }
  195. begin
  196.   { Get current directory and save it for later }
  197.   GetDir( 0 , TheOldString );
  198.   { Check for need to add trailing \ }
  199.   WorkingDir := TheOldString;
  200.   WorkingDir := ScrollBox1.TheFWB.ForceTrailingBackSlash( WorkingDIr );
  201.   { Display the Windows-based directory input form }
  202.   TheResult := DestDDForm.ShowModal;
  203.   { If not cancelled do the copy }
  204.   if TheResult = mrOK then
  205.   begin
  206.     { Get the target directory with \ OK }
  207.     TargetDir := DestDDForm.GetTargetDirectory;
  208.     { Show the hourglass to indicate waiting }
  209.     Screen.Cursor := crHourGlass;
  210.     { Set up to get all current selections }
  211.     ThePosition := 1;
  212.     finished := false;
  213.     while not finished do
  214.     begin
  215.       { Call generic file getting routine based on current view}
  216.       case CurrentView of
  217.         1 : CurrentName := ScrollBox1.GetNextSelection( WorkingDir ,
  218.              ThePosition );
  219.         2 : CurrentName := FileListBox1.GetNextSelection( WorkingDir ,
  220.              ThePosition );
  221.       end;
  222.       { If returns blank string then out of selections }
  223.       if CurrentName = '' then finished := true else
  224.       begin
  225.         { If a directory signal error }
  226.         if (( FileGetAttr( CurrentName ) and faDirectory ) = faDirectory ) then
  227.         begin
  228.           if MessageDlg( 'Move Directory ' + CurrentName + ' to ' + TargetDir +
  229.            '?' , mtConfirmation , mbYesNoCancel , 0 ) = mrYes then
  230.             ScrollBox1.TheFWB.RecursivelyMoveDirectory( CurrentName ,
  231.              TargetDir );
  232.         end
  233.         else
  234.         begin
  235.           Scrollbox1.TheFWB.MoveTheFile( CurrentName , TargetDir );
  236.         end;
  237.       end;
  238.       { Reset to normal cursor }
  239.       Screen.Cursor := crDefault;
  240.     end;
  241.   end;
  242.   { Reset to the original directory }
  243.   ChDir( TheOldString );
  244.   if CurrentView = 1 then { Reset icon display if in view }
  245.    ScrollBox1.Update else FileListBox1.Update; { Otherwise update the FLB }
  246. end;
  247.  
  248. { Delphi wrote this, use it to delete files which are selected }
  249. procedure TCCFileMgrForm.BitBtn3Click(Sender: TObject);
  250. var ThePosition  : Integer;       { Loop counter   }
  251.     CurrentName ,                 { Holds work name}
  252.     TheOldString : String;        { Holds Dir      }
  253.     finished     : Boolean;       { Loop control   }
  254.     WorkingDir   : String;        { Holds mod wd   }
  255. begin
  256.   { Get current directory and save it for later }
  257.   GetDir( 0 , TheOldString );
  258.   { Check for need to add trailing \ }
  259.   WorkingDir := TheOldString;
  260.   WorkingDir := ScrollBox1.TheFWB.ForceTrailingBackSlash( WorkingDIr );
  261.   { Set up to do loop for selected files }
  262.   ThePosition := 1;
  263.   finished := false;
  264.   while not finished do
  265.   begin
  266.     { Call generic file getting routine based on current view}
  267.     case CurrentView of
  268.       1 : CurrentName := ScrollBox1.GetNextSelection( WorkingDir ,
  269.            ThePosition );
  270.       2 : CurrentName := FileListBox1.GetNextSelection( WorkingDir ,
  271.            ThePosition );
  272.     end;
  273.     { if returns blank string out of selections }
  274.     if CurrentName = '' then finished := true else
  275.     begin
  276.       { If its a directory signal error }
  277.       if (( FileGetAttr( CurrentName ) and faDirectory ) = faDirectory ) then
  278.       begin
  279.         if MessageDlg( 'Delete Directory ' + CurrentName + '?' , mtConfirmation,
  280.          mbYesNoCancel , 0 ) = mrYes then
  281.         begin
  282.           ScrollBox1.TheFWB.RecursivelyDeleteDirectory( CurrentName );
  283.           Scrollbox1.TheFWB.RemoveDirectory( Currentname );
  284.         end;
  285.       end
  286.       else
  287.       begin
  288.         { Otherwise get confirmation message and if OKed delete file }
  289.         if MessageDlg( 'Delete file ' + CurrentName + '?', mtConfirmation ,
  290.          mbYesNoCancel , 0 ) = mrYes then
  291.         begin
  292.           ScrollBox1.TheFWB.DeleteTheFile( Currentname );
  293.         end;
  294.       end;
  295.     end;
  296.   end;
  297.   if CurrentView = 1 then { Reset icon display if in view }
  298.    ScrollBox1.Update else FileListBox1.Update; { Otherwise update the FLB }
  299. end;
  300.  
  301. { Delphi wrote this; use it to rename selected files }
  302. procedure TCCFileMgrForm.BitBtn4Click(Sender: TObject);
  303. var ThePosition  : Integer;       { Loop counter   }
  304.     CurrentName ,                 { Holds work name}
  305.     TheOldString : String;        { Holds Dir      }
  306.     finished     : Boolean;       { Loop control   }
  307.     WorkingDir   : String;        { Holds mod wd   }
  308. begin
  309.   { Get current directory for later }
  310.   GetDir( 0 , TheOldString );
  311.   { Check for need to add trailing \ }
  312.   WorkingDir := TheOldString;
  313.   WorkingDir := ScrollBox1.TheFWB.ForceTrailingBackSlash( WorkingDIr );
  314.   { Set up to do loop for selected files }
  315.   ThePosition := 1;
  316.   finished := false;
  317.   while not finished do
  318.   begin
  319.     { Call generic file getting routine based on current view}
  320.     case CurrentView of
  321.       1 : CurrentName := ScrollBox1.GetNextSelection( WorkingDir ,
  322.            ThePosition );
  323.       2 : CurrentName := FileListBox1.GetNextSelection( WorkingDir ,
  324.            ThePosition );
  325.     end;
  326.     { If returns blank string then out of selections }
  327.     if CurrentName = '' then finished := true else
  328.     begin
  329.       { Otherwise set up the opendialog with filename and caption }
  330.       OpenDialog1.Filename := ExtractFilename( CurrentName );
  331.       { Use this to prevent error from changing directories }
  332.       OpenDialog1.Options := [ofNoChangeDir];
  333.       OpenDialog1.Title := 'Rename File';
  334.       { If not cancelled then do rename or signal error }
  335.       if OpenDialog1.Execute then
  336.       begin
  337.         ScrollBox1.TheFWB.RenameTheFile( CurrentName , OpenDialog1.Filename );
  338.       end;
  339.     end;
  340.   end;
  341.   if CurrentView = 1 then { Reset icon display if in view }
  342.    ScrollBox1.Update else FileListBox1.Update; { Otherwise update the FLB }
  343. end;
  344.  
  345. { Delphi wrote this; use it to make a new directory under current one }
  346. procedure TCCFileMgrForm.BitBtn5Click(Sender: TObject);
  347. begin
  348.   { Set up the dialog to get the new directory name }
  349.   OpenDialog2.FileName := '*.*';
  350.   OpenDialog2.Title := 'Enter Directory Name';
  351.   if OpenDialog1.Execute then
  352.   begin
  353.     { If not cancelled make new directory }
  354.     Scrollbox1.TheFWB.CreateNewDirectory( OpenDialog1.Filename );
  355.   end;
  356.   if CurrentView = 1 then { Reset icon display if in view }
  357.    ScrollBox1.Update else FileListBox1.Update; { Otherwise update the FLB }
  358. end;
  359.  
  360. { Delphi wrote this; use it to handle refreshing the scrollbox }
  361. procedure TCCFileMgrForm.FormPaint(Sender: TObject);
  362. var CurrentDirectory : String; { Get current dir }
  363. begin
  364.   { If updated, do refresh }
  365.   if ScrollBox1.IconsNeedRefreshing then
  366.   begin
  367.     Scrollbox1.ClearTheFIPs;
  368.     ScrollBox1.IconsNeedRefreshing := false;
  369.     GetDir( 0 , CurrentDirectory );
  370.     { Force trailing backslash }
  371.     CurrentDirectory := ScrollBox1.TheFWB.ForceTrailingBackSlash(
  372.      CurrentDirectory );
  373.     { Set the label to the new directory }
  374.     Label1.Caption := UpperCase( CurrentDirectory );
  375.     { Do the update }
  376.     ScrollBox1.GetIconsForEntireDirectory( CurrentDirectory );
  377.   end;
  378. end;
  379.  
  380. { Delphi wrote this; use it to reset the current view Icons/List }
  381. procedure TCCFileMgrForm.BitBtn8Click(Sender: TObject);
  382. var TheOldString : String; { Use to get current directory }
  383. begin
  384.   { Reset currentview }
  385.   if CurrentView = 1 then CurrentView := 2 else
  386.    CurrentView := 1;
  387.   { either show the windows boxes or the scrollbox }
  388.   case CurrentView of
  389.     1 : begin
  390.           { Make the listboxes invisible by changing align and width }
  391.           FileListBox1.Visible := false;
  392.           FileListBox1.Align := alNone;
  393.           FileListBox1.Width := 0;
  394.           DirectoryListBox1.Visible := false;
  395.           DirectoryListBox1.align := alNone;
  396.           DirectoryListBox1.Width := 0;
  397.           { Keep them from getting mouse clicks }
  398.           FileListBox1.Enabled := false;
  399.           DirectoryListBox1.Enabled := false;
  400.           { Have the scrollbox get mouse and be seen  by resetting align/wid}
  401.           Scrollbox1.align := alClient;
  402.           Scrollbox1.width := Panel1.Width - 32;
  403.           ScrollBox1.Enabled := true;
  404.           { Tell the scrollbox to repaint itself just in case }
  405.           ScrollBox1.Update;
  406.         end;
  407.     2 : begin
  408.           { Make the listboxes visible by resetting align and width}
  409.           FileListBox1.Visible := true;
  410.           DirectoryListBox1.Visible := true;
  411.           DirectoryListBox1.width := 145;
  412.           DirectoryListBox1.align := alLeft;
  413.           FileListBox1.align := alClient;
  414.           FileListBox1.Width := Panel1.Width - 32 - DirectoryListBox1.Width;
  415.           { Have them getting mouse clicks }
  416.           FileListBox1.Enabled := true;
  417.           DirectoryListBox1.Enabled := true;
  418.           { Have the scrollbox not get mouse and not be seen via align/width}
  419.           ScrollBox1.Enabled := false;
  420.           ScrollBox1.Visible := false;
  421.           ScrollBox1.align := alNone;
  422.           ScrollBox1.Width := 0;
  423.         end;
  424.   end;
  425.   Invalidate;
  426. end;
  427.  
  428. { Delphi wrote this; use it to do a file search display }
  429. procedure TCCFileMgrForm.BitBtn9Click(Sender: TObject);
  430. var CurrentDirectory : String; { Holds current directory }
  431. begin
  432.   { Set up and run the search dialog }
  433.   OpenDialog2.FileName := '*.*';
  434.   { if not cancelled do the search }
  435.   if OpenDialog2.Execute then
  436.   begin
  437.     { Get current directory }
  438.     GetDir( 0 , CurrentDirectory );
  439.     { Force trailing backslash }
  440.     CurrentDirectory :=
  441.      ScrollBox1.TheFWB.ForceTrailingBackSlash( CurrentDirectory );
  442.     { display recursive search results }
  443.     Scrollbox1.DisplayRecursiveSearchResults(
  444.      CurrentDirectory + OpenDialog2.Filename );
  445.     Label1.Caption := 'Search Results for ' + CurrentDirectory +
  446.      OpenDialog2.FileName;
  447.   end;
  448. end;
  449.  
  450. { Delphi wrote this; use it to set a file's properties }
  451. procedure TCCFileMgrForm.BitBtn6Click(Sender: TObject);
  452. var ThePosition  : Integer;       { Loop counter   }
  453.     CurrentName ,                 { Holds work name}
  454.     TheOldString : String;        { Holds Dir      }
  455.     finished     : Boolean;       { Loop control   }
  456.     WorkingDir   : String;        { Holds mod wd   }
  457. begin
  458.   { Get current directory for later }
  459.   GetDir( 0 , TheOldString );
  460.   ThePosition := 1;
  461.   { Check for need to add trailing \ }
  462.   Workingdir := TheOldString;
  463.   WorkingDir := ScrollBox1.TheFWB.ForceTrailingBackSlash( WorkingDIr );
  464.   { Call generic file getting routine based on current view}
  465.   case CurrentView of
  466.     1 : CurrentName := ScrollBox1.GetNextSelection( WorkingDir ,
  467.          ThePosition );
  468.     2 : CurrentName := FileListBox1.GetNextSelection( WorkingDir ,
  469.          ThePosition );
  470.   end;
  471.   { If nothing selected then abort (gets ..!) }
  472.   if CurrentName = '' then
  473.   begin
  474.     MessageDlg( 'No File Selected!' , mtError , [mbOK] , 0 );
  475.     exit;
  476.   end
  477.   else
  478.   begin
  479.     { Otherwise set up the properties form and show it }
  480.     CCFMPropsForm.WorkingFileName := CurrentName;
  481.     CCFMPropsForm.ThePosition := ThePosition;
  482.     CCFMPropsForm.BitBtn4.Enabled := true;
  483.     CCFMPropsForm.Initialize;
  484.     CCFMPropsForm.ShowModal;
  485.   end;
  486.   if CurrentView = 1 then { Reset icon display if in view }
  487.    ScrollBox1.Update else FileListBox1.Update; { Otherwise update the FLB }
  488. end;
  489.  
  490. { Delphi wrote this; use it to drag and drop files for copying }
  491. procedure TCCFileMgrForm.BitBtn1DragDrop(Sender, Source: TObject; X,
  492.   Y: Integer);
  493. var CurrentName ,                 { Holds work name}
  494.     TheOldString : String;        { Holds Dir      }
  495.     TargetDir    : String;        { target of op   }
  496.     TheResult    : Integer;       { Modal res hold }
  497. begin
  498.   { Make sure source is indeed a FileIconPanel }
  499.   with Source as TFileIconPanel do
  500.   begin
  501.     { Get current directory and save it for later }
  502.     GetDir( 0 , TheOldString );
  503.     { Display the Windows-based directory input form }
  504.     TheResult := DestDDForm.ShowModal;
  505.     { If not cancelled do the copy }
  506.     if TheResult = mrOK then
  507.     begin
  508.       CurrentName := FTheName;
  509.       { Get the target directory with \ OK }
  510.       TargetDir := DestDDForm.GetTargetDirectory;
  511.       { If a directory signal and do recursive operation }
  512.       if (( FileGetAttr( CurrentName ) and faDirectory ) = faDirectory ) then
  513.       begin
  514.         if MessageDlg( 'Copy Directory ' + CurrentName + ' to ' + TargetDir
  515.          +'?', mtConfirmation , mbYesNoCancel , 0 ) = mryes then
  516.         begin
  517.           ScrollBox1.TheFWB.RecursivelyCopyDirectory( CurrentName ,
  518.            TargetDir );
  519.         end;
  520.       end
  521.       else
  522.       begin
  523.         { Do the copy }
  524.         Scrollbox1.TheFWB.CopyTheFile( CurrentName , TargetDir );
  525.       end;
  526.       { Reset to the original directory }
  527.       ChDir( TheOldString );
  528.     end;
  529.   end;
  530. end;
  531.  
  532. { Delphi wrote this; use it to generically OK DnD from FIPs }
  533. procedure TCCFileMgrForm.BitBtn1DragOver(Sender, Source: TObject; X,
  534.   Y: Integer; State: TDragState; var Accept: Boolean);
  535. begin
  536.   { Only accept from FileIconPanel components }
  537.   if Source is TFileIconPanel then Accept := true else Accept := false;
  538. end;
  539.  
  540. { Delphi wrote this; use it to accept Drag and Drop moving }
  541. procedure TCCFileMgrForm.BitBtn2DragDrop(Sender, Source: TObject; X,
  542.   Y: Integer);
  543. var CurrentName ,                 { Holds work name}
  544.     TheOldString : String;        { Holds Dir      }
  545.     TargetDir    : String;        { target of op   }
  546.     TheResult       : Integer;    { Modal res hold }
  547. begin
  548.   with Source as TFileIconPanel do
  549.   begin
  550.     { Get current directory and save it for later }
  551.     GetDir( 0 , TheOldString );
  552.     { Display the Windows-based directory input form }
  553.     TheResult := DestDDForm.ShowModal;
  554.     { If not cancelled do the copy }
  555.     if TheResult = mrOK then
  556.     begin
  557.       { Get the target directory with \ OK }
  558.       TargetDir := DestDDForm.GetTargetDirectory;
  559.       { If Copyfile returns false an error occurred }
  560.       CurrentName := FTheName;
  561.       { If a directory signal and do recursion }
  562.       if (( FileGetAttr( CurrentName ) and faDirectory ) = faDirectory ) then
  563.       begin
  564.         if MessageDlg( 'Move Directory ' + CurrentName + ' to ' + TargetDir +
  565.          '?' , mtConfirmation , mbYesNoCancel , 0 ) = mrYes then
  566.           ScrollBox1.TheFWB.RecursivelyMoveDirectory( CurrentName ,
  567.            TargetDir );
  568.       end
  569.       else
  570.       begin  { Do the move }
  571.         Scrollbox1.TheFWB.MoveTheFile( CurrentName , TargetDir );
  572.         ChDir( TheOldString );
  573.       end;
  574.       { Refresh display }
  575.       ScrollBox1.Update;
  576.     end;
  577.   end;
  578. end;
  579.  
  580. { Delphi wrote this; use it to do drag and drop deletes }
  581. procedure TCCFileMgrForm.BitBtn3DragDrop(Sender, Source: TObject; X,
  582.   Y: Integer);
  583. var CurrentName : String;  { Holds work name}
  584. begin
  585.   with Source as TFileIconPanel do
  586.   begin
  587.     CurrentName := FTheName;
  588.     { If its a directory signal and do recursive delete }
  589.     if (( FileGetAttr( CurrentName ) and faDirectory ) = faDirectory ) then
  590.     begin
  591.       if MessageDlg( 'Delete Directory ' + CurrentName + '?' , mtConfirmation ,
  592.        mbYesNoCancel , 0 ) = mrYes then
  593.       begin
  594.         Scrollbox1.TheFWB.RecursivelyDeleteDirectory( CurrentName );
  595.         Scrollbox1.TheFWB.RemoveDirectory( CurrentName );
  596.       end;
  597.     end
  598.     else
  599.     begin
  600.       { Otherwise get confirmation message and if OKed delete file }
  601.       if MessageDlg( 'Delete file ' + CurrentName + '?', mtConfirmation ,
  602.        mbYesNoCancel , 0 ) = mrYes then
  603.       begin
  604.         Scrollbox1.TheFWB.DeleteTheFile( CurrentName );
  605.       end;
  606.     end;
  607.     { Refresh Display }
  608.     Scrollbox1.Update;
  609.   end;
  610. end;
  611.  
  612. { Delphi wrote this; use it to do drag and drop renames }
  613. procedure TCCFileMgrForm.BitBtn4DragDrop(Sender, Source: TObject; X,
  614.   Y: Integer);
  615. var CurrentName : String;  { Holds work name}
  616. begin
  617.   with Source as TFileIconPanel do
  618.   begin
  619.     CurrentName := FTheName;
  620.     { If a directory signal error }
  621.     { Otherwise set up the opendialog with filename and caption }
  622.     OpenDialog2.Filename := ExtractFilename( CurrentName );
  623.     { Use this to prevent error from changing directories }
  624.     OpenDialog2.Options := [ofNoChangeDir];
  625.     OpenDialog2.Title := 'Rename File';
  626.     { If not cancelled then do rename or signal error }
  627.     if OpenDialog2.Execute then
  628.     begin
  629.       Scrollbox1.TheFWB.RenameTheFile( CurrentName , OpenDialog1.Filename );
  630.     end;
  631.     { Refresh the display }
  632.     ScrollBox1.Update;
  633.   end;
  634. end;
  635.  
  636. end.
  637.